/*    This file is part of unfy.
 *
 *    Unfy is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    Unfy is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with unfy.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef UNFP_H
#define UNFP_H

/*
Include:
something with size_t
#include <rid.h>
#include <unfy/unfy.h>

#include <unfy/unfp.h>
*/

#ifndef STYLE_9
#include <rid.h>
#include <unfy/unfy.h>
#endif

typedef enum {
	UNFP_TNIL = 0,
	UNFP_CONST,
	UNFP_ORDER,
	UNFP_IGN,
	UNFP_VAR,
	UNFP_LOPEN,
	UNFP_LCLOSE,
	UNFP_LNIL,
	UNFP_BOPEN,
	UNFP_BCLOSE,
	UNFP_BNIL,
} Unfp_type;

/* term */

void
unfp_term_print(const Unfy_term *term);

Unfy_term *
unfp_term_parse(const char *str, size_t *pos,
		const char **error, Unfy_recycle *rec);

int
unfp_term_ser(const Unfy_term *term, unsigned char **buf,
	      size_t *size, size_t *pos);

size_t
unfp_term_write(const Unfy_term *term, unsigned char *buf);

size_t
unfp_term_len(const Unfy_term *term);

int
unfp_term_deser(Unfy_term **term, const unsigned char *buf,
		size_t *pos, Unfy_recycle *rec);

const char *
unfp_term_deserable(const unsigned char *buf, size_t *pos, const size_t max);

/* list */

void
unfp_list_print(const Unfy_list *list);

int
unfp_list_parse(Unfy_list **list, const char *str, size_t *pos,
		const char **error, Unfy_recycle *rec);

size_t
unfp_list_len(const Unfy_list *list);

size_t
unfp_list_write(const Unfy_list *list, unsigned char *buf);

int
unfp_list_ser(const Unfy_list *list, unsigned char **buf,
	      size_t *size, size_t *pos);

int
unfp_list_deser(Unfy_list **list, const unsigned char *buf,
		size_t *pos, Unfy_recycle *rec);

const char *
unfp_list_deserable(const unsigned char *buf, size_t *pos, const size_t max);

/* bind */

void
unfp_bind_print(const Unfy_bind *bind);

void
unfp_binds_print(const Unfy_bind *binds, int level);

size_t
unfp_bind_len(const Unfy_bind *bind);

size_t
unfp_bind_write(const Unfy_bind *bind, unsigned char *buf);

int
unfp_bind_ser(const Unfy_bind *bind, unsigned char **buf,
	      size_t *size, size_t *pos);

int
unfp_bind_deser(Unfy_bind **bind, const unsigned char *buf,
		size_t *pos, Unfy_recycle *rec);

const char *
unfp_bind_deserable(const unsigned char *buf, size_t *pos, const size_t max);

/* util */

int
unfp_space(const char *str, size_t *pos, const char **error);

#endif
